﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UpPic.aspx.cs" Inherits="WinnerCMS.WebUI.Admin.Window.UpPic" %>

<!doctype html>
<html>
<head runat="server">
    <title>上传图片</title>
    <meta charset="utf-8">
    <meta content="no-cache" http-equiv="Pragma" />
    <%: Scripts.Render("~/Scripts/AdminBase") %>
    
    
    <%: Styles.Render("~/Content/Bootstrap/css") %>
    <script type="text/javascript">
    var flag=false;
    function DrawImage(ImgD)
    {
	    var image=new Image();
	    image.src=ImgD.src;
	    if(image.width>0 && image.height>0)
	    {
		    flag=true;
		    if(image.width/image.height>= 120/80)
		    {
			    if(image.width>120)
			    {
				    ImgD.width=120;
				    ImgD.height=(image.height*120)/image.width;
			    }
			    else
			    {
				    ImgD.width=image.width;
				    ImgD.height=image.height;
			    }
			    ImgD.alt=image.width+"×"+image.height;
		    }
		    else{
			    if(image.height>80){
				    ImgD.height=80;
				    ImgD.width=(image.width*80)/image.height;
			    }
			    else{
				    ImgD.width=image.width;
				    ImgD.height=image.height;
			    }
			    ImgD.alt=image.width+"×"+image.height;
		    }
	    }
    }

    function FileChange(value)
    {
	    flag=false;
	    document.all.uploadimage.width=10;
	    document.all.uploadimage.height=10;
	    document.all.uploadimage.alt="";
	    document.all.uploadimage.src=value;
    }
 
	function ClickRetrun( v )
	{
	    window.returnValue = v;
	    window.close();
	}
 
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <table>
        <tr>
            <td class="RowStyle">
                上传缩略图：
            </td>
            <td>
                <asp:FileUpload ID="FileUpload1" runat="server" Width="322px" onchange="javascript:FileChange(this.value);" />
                &nbsp;&nbsp;&nbsp;
                <asp:Button ID="btnUpLoad" runat="server" OnClick="btnUpLoad_Click" Text="上传" Cssclass="btn btn-default" />
                <br />
                <img id="uploadimage" height="10" width="10" alt="" onload="javascript:DrawImage(this);" />
            </td>
        </tr>
        </table>
   
    </form>
</body>
</html>
